package com.cjm.one.security.custom;

import java.security.SecureRandom;
import java.util.Base64;

public class SaltGenerator {

    private static final int SALT_LENGTH = 16; // 盐值长度

    public static String generateSalt() {
        SecureRandom secureRandom = new SecureRandom();
        byte[] salt = new byte[SALT_LENGTH];
        secureRandom.nextBytes(salt); // 生成随机字节
        return Base64.getEncoder().encodeToString(salt); // 返回 Base64 编码的盐值
    }

    public static void main(String[] args) {
        // 测试生成盐值
        String salt = generateSalt();
        System.out.println("生成的盐值: " + salt);
    }
}